package com.example.demo.service;

import com.example.demo.service.impl.DatabaseTableDataService;
import com.example.demo.service.impl.ExcelTableDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TableDataServiceFactory {

    @Autowired
    private DatabaseTableDataService databaseService;

    @Autowired
    private ExcelTableDataService excelService;

    public TableDataService getService(String sourceType) {
        if ("database".equalsIgnoreCase(sourceType)) {
            return databaseService;
        } else if ("excel".equalsIgnoreCase(sourceType)) {
            return excelService;
        } else {
            throw new IllegalArgumentException("不支持的数据源类型: " + sourceType);
        }
    }
}    